package com.room.controller.dormman;

import com.room.pojo.Dormman;
import com.room.pojo.Student;
import com.room.service.DormmanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @创建人 lin
 * @创建时间 2019/10/14
 * @描述
 */
@RestController
@RequestMapping("/dormman/manager")
public class DormmanController {
    @Autowired
    DormmanService dormmanService;

    /**
     * 获得学生的分页数据
     * @param page
     * @param size
     * @return返回学生的分页数据
     */
    @RequestMapping(value = "/dormman",method = RequestMethod.GET)
    public Map<String,Object> getDormmandentByPage(
            @RequestParam(defaultValue = "1")Integer page,
            @RequestParam(defaultValue = "6")Integer size
    ){

        Map<String,Object> map = new HashMap<String,Object>();
        List<Dormman> dormmans = dormmanService.getDormmanByPage(page,size);
        long total = dormmanService.getTotal();
        map.put("dormmans",dormmans);
        map.put("total",total);
        return map;
    }
}
